﻿# CMakeList.txt: 顶层 CMake 项目文件，在此处执行全局配置
# 并包含子项目。
#
cmake_minimum_required (VERSION 3.8)

project ("YouChatGateServer")

# 包含子项目。
add_subdirectory ("YouChatGateServer")


# 设置C++标准
set(CMAKE_CXX_STANDARD 11)



# 设置 CMP0079 策略为 NEW
cmake_policy(SET CMP0079 NEW)

# mysql
set(MYSQL_INC_DIR  "D:\\Software\\c++\\mysql-connector-c++-8.3.0-winx64\\include")
set(MYSQL_LIB_DIR "D:\\Software\\c++\\mysql-connector-c++-8.3.0-winx64\\lib64\\vs14\\debug")


# hiredis
set(HIREDIS_INC_DIR  "D:\\Software\\c++\\windows-redis\\deps\\hiredis")
set(HIREDIS_LIB_DIR "D:\\Software\\c++\\windows-redis\\msvs\\x64\\Debug")


 # boost
set(Boost_INC_DIR "D:/Software/c++/boost_1_87_0")  # 根据自己的version.hpp文件对应的父路径，见下图
set(Boost_LIB_DIR "D:/Software/c++/boost_1_87_0/stage/lib")  # 编译获得的lib路径

# protobuf
set(PROTOBUF_INC_DIR "D:\\Software\\c++\\grpc\\grpc\\third_party\\protobuf\\src")
set(PROTOBUF_LIB_DIR "D:\\Software\\c++\\grpc\\visualgrpc\\third_party\\protobuf\\Debug")

# grpc
set(gRPC_INC_DIR
    "D:/Software/c++/grpc/grpc/third_party/re2"
    "D:/Software/c++/grpc/grpc/third_party/address_sorting/include"
    "D:/Software/c++/grpc/grpc/third_party/abseil-cpp"
    "D:/Software/c++/grpc/grpc/third_party/protobuf/src"
    "D:/Software/c++/grpc/grpc/include"
)

set(gRPC_LIB_DIR
    "D:/Software/c++/grpc/visualgrpc/third_party/re2/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/types/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/synchronization/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/status/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/random/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/flags/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/debugging/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/container/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/hash/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/boringssl-with-bazel/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/numeric/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/time/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/base/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/abseil-cpp/absl/strings/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/protobuf/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/zlib/Debug"
    "D:/Software/c++/grpc/visualgrpc/Debug"
    "D:/Software/c++/grpc/visualgrpc/third_party/cares/cares/lib/Debug"
)


# 包含头文件路径（包括其他目录）
target_include_directories(YouChatGateServer 
    PRIVATE 
     ${PROTOBUF_INC_DIR} ${gRPC_INC_DIR}  ${Boost_INC_DIR} ${HIREDIS_INC_DIR}  ${MYSQL_INC_DIR}
)
# 链接 mysql 库
target_link_libraries(YouChatGateServer PRIVATE mysqlcppconn mysqlcppconn8 )
# 链接 hiredis 库
target_link_libraries(YouChatGateServer PRIVATE hiredis Win32_Interop)
# 链接 boost 库
target_link_libraries(YouChatGateServer PRIVATE 
libboost_filesystem-vc142-mt-gd-x64-1_87
libboost_system-vc142-mt-gd-x64-1_87
libboost_atomic-vc142-mt-gd-x64-1_87
)

# 链接 protobuf 库
target_link_libraries(YouChatGateServer PRIVATE libprotobufd libprotocd)


# 链接 grpc 库
target_link_libraries(YouChatGateServer PRIVATE 
libprotobufd.lib
gpr.lib
grpc.lib
grpc++.lib
grpc++_reflection.lib
address_sorting.lib
ws2_32.lib
cares.lib
zlibstaticd.lib
upb.lib
ssl.lib
crypto.lib
absl_bad_any_cast_impl.lib
absl_bad_optional_access.lib
absl_bad_variant_access.lib
absl_base.lib
absl_city.lib
absl_civil_time.lib
absl_cord.lib
absl_debugging_internal.lib
absl_demangle_internal.lib
absl_examine_stack.lib
absl_exponential_biased.lib
absl_failure_signal_handler.lib
absl_flags.lib
absl_flags_config.lib
absl_flags_internal.lib
absl_flags_marshalling.lib
absl_flags_parse.lib
absl_flags_program_name.lib
absl_flags_usage.lib
absl_flags_usage_internal.lib
absl_graphcycles_internal.lib
absl_hash.lib
absl_hashtablez_sampler.lib
absl_int128.lib
absl_leak_check.lib
absl_leak_check_disable.lib
absl_log_severity.lib
absl_malloc_internal.lib
absl_periodic_sampler.lib
absl_random_distributions.lib
absl_random_internal_distribution_test_util.lib
absl_random_internal_pool_urbg.lib
absl_random_internal_randen.lib
absl_random_internal_randen_hwaes.lib
absl_random_internal_randen_hwaes_impl.lib
absl_random_internal_randen_slow.lib
absl_random_internal_seed_material.lib
absl_random_seed_gen_exception.lib
absl_random_seed_sequences.lib
absl_raw_hash_set.lib
absl_raw_logging_internal.lib
absl_scoped_set_env.lib
absl_spinlock_wait.lib
absl_stacktrace.lib
absl_status.lib
absl_strings.lib
absl_strings_internal.lib
absl_str_format_internal.lib
absl_symbolize.lib
absl_synchronization.lib
absl_throw_delegate.lib
absl_time.lib
absl_time_zone.lib
absl_statusor.lib
re2.lib
)


# 添加库文件路径
target_link_directories(YouChatGateServer PRIVATE   ${PROTOBUF_LIB_DIR} 
     ${gRPC_LIB_DIR} ${Boost_LIB_DIR}  ${HIREDIS_LIB_DIR} ${MYSQL_LIB_DIR}
)
